﻿using System.Text.RegularExpressions;
using System;
using System.Collections.Generic;

//namespace DataModel.Validation.ValidationRules
namespace FlexPlatform.DataModel.Validation.Generic_ValidationRules
{
    public class RegularExpression_Rule: ValidationRuleBase
    {
        public const string CNP_Rule= "^[1-2]{1}[0-9]{2}(([0][1-9])|([1][0-2])){1}(([0][1-9])|([1-2][0-9])|([3][0-1])){1}([0-9]){6}$";
        public const string Email_Rule= @"^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$";
        public const string NoSymbols_Rule = "^[a-zA-Z0-9]+$";
        public const string OnlyDigits_Rule = "^[0-9]+$";
        public const string OnlyLetters_Rule = "^[a-zA-Z]+$";
        public const string PhoneNumber_Rule = "^[0-9]{10,14}$";

        protected sealed override bool ValueIsOk(object proposedValue)
        {
            if (!Regex.IsMatch((string)proposedValue, (string)clsSpecificValue))
            {
                return false;
            }

            else
            {
                return true;
            }
        }
    }
}
